<%-- 
    Document   : AddSach
    Created on : Jun 4, 2013, 10:16:43 AM
    Author     : quannq
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>

<form:form id="validate" action="${pageContext.request.contextPath}/admin/updateSach" 
           commandName="sach" method="post" enctype="multipart/form-data">    
    <form:hidden path="masach" />
    <form:hidden path="anhbia" />
    <table width="924" align="center" cellpadding="5" cellspacing="5" border="1" style='border-collapse:collapse;'>
        <tr>
            <td colspan="4" align="center"><h2>THÔNG TIN SÁCH</h2></td>
        </tr>
        <tr>
            <td width="98"><form:label path="tensach">Tên Sách:</form:label></td>
            <td width="322"><form:input path="tensach" class="validate[required]"/></td>
            <td width="131"><form:label path="cannang">Trọng Lượng:</form:label></td>
            <td width="298"><form:input path="cannang" class="validate[required,custom[onlyNumber]]"/></td>
        </tr>
        <tr>
            <td><form:label path="loaisach">Loại Sách:</form:label></td>
                <td>    
                <form:select path="loaisach" cssStyle="width:215px">
                    <c:forEach items="${loaiSach}" var="loaisach">
                        <c:if test="${loaisach.maloaisach eq sach.loaisach.maloaisach}">
                            <form:option selected="true" value="${loaisach.maloaisach}">${loaisach.tenloaisach}</form:option>
                        </c:if>
                        <c:if test="${loaisach.maloaisach != sach.loaisach.maloaisach}">
                            <form:option value="${loaisach.maloaisach}">${loaisach.tenloaisach}</form:option>
                        </c:if>
                    </c:forEach>
                </form:select>
            </td>
            <td><form:label path="sotrang">Số Trang</form:label></td>
            <td><form:input path="sotrang" class="validate[required,custom[onlyNumber]]"/></td>
        </tr>
        <tr>
            <td><form:label path="loaibia">Loại Bia</form:label></td>
                <td>    
                <form:select path="loaibia" cssStyle="width:215px">
                    <c:forEach items="${loaiBia}" var="loaibia">
                        <c:if test="${loaibia.maloaibia eq sach.loaibia.maloaibia}">
                            <form:option selected="true" value="${loaibia.maloaibia}">${loaibia.tenloaibia}</form:option>
                        </c:if>
                        <c:if test="${loaibia.maloaibia != sach.loaibia.maloaibia}">
                            <form:option selected="true" value="${loaibia.maloaibia}">${loaibia.tenloaibia}</form:option>
                        </c:if>
                    </c:forEach>
                </form:select>
            </td>
            <td><form:label path="kichthuoc">Kích Thước</form:label></td>
            <td><form:input path="kichthuoc" class="validate[required]"/></td>
        </tr>
        <tr>
            <td><form:label path="tacgia">Tác Giả</form:label></td>
                <td>
                <form:select path="tacgia" cssStyle="width:215px">
                    <c:forEach items="${tacGia}" var="tacgia">
                        <c:if test="${tacgia.matacgia eq sach.tacgia.matacgia}">
                            <form:option selected="true" value="${tacgia.matacgia}">${tacgia.tentacgia}</form:option>
                        </c:if>
                        <c:if test="${tacgia.matacgia != sach.tacgia.matacgia}">
                            <form:option value="${tacgia.matacgia}">${tacgia.tentacgia}</form:option>
                        </c:if>
                    </c:forEach>
                </form:select>
            </td>
            <td rowspan="5"><form:label path="noidung">Nội Dung</form:label></td>
            <td rowspan="5"><form:textarea path="noidung" cols="17" rows="10" cssStyle="width:215px" /></td>
        </tr>
        <tr>
            <td><form:label path="theloai1">Thể Loại 1</form:label></td>
                <td>
                <form:select path="theloai1" cssStyle="width:215px"
                             onchange="loadList('tl2','loadTL2',this.value);updateSelectTag('tl3');">
                    <c:forEach items="${theLoai1}" var="theloai1">
                        <c:if test="${sach.theloai1.matl1 eq theloai1.matl1}">
                            <form:option selected="true" value="${theloai1.matl1}">${theloai1.tentl1}</form:option>
                        </c:if>
                        <c:if test="${sach.theloai1.matl1 != theloai1.matl1}">
                            <form:option value="${theloai1.matl1}">${theloai1.tentl1}</form:option>
                        </c:if>
                    </c:forEach>
                </form:select>
            </td>
        </tr>


        <tr>
            <td>Thể Loại 2 :</td>
            <td id="tl2">
                <form:select path="theloai2" cssStyle="width:215px" 
                             onchange="loadList('tl3','loadTL3',this.value);">
                    <c:forEach items="${sach.theloai1.theloai2s}" var="theloai2">
                        <c:if test="${theloai2.matl2 eq sach.theloai2.matl2}">
                            <form:option selected="true" value="${theloai2.matl2}">${theloai2.tentl2}</form:option>
                        </c:if>
                        <c:if test="${theloai2.matl2 != sach.theloai2.matl2}">
                            <form:option value="${theloai2.matl2}">${theloai2.tentl2}</form:option>
                        </c:if>
                    </c:forEach>
                </form:select>
            </td>
        </tr>
        <tr>
            <td>Thể Loại 3 :</td>
            <td id="tl3">
                <form:select path="theloai3" cssStyle="width:215px">
                    <c:forEach items="${sach.theloai3.theloai2.theloai3s}" var="theloai3">
                        <c:if test="${theloai3.matl3 eq sach.theloai3.matl3}">
                            <form:option value="${theloai3.matl3}" selected="true">${theloai3.tentl3}</form:option>                        
                        </c:if>
                        <c:if test="${theloai3.matl3 != sach.theloai3.matl3}">
                            <form:option value="${theloai3.matl3}">${theloai3.tentl3}</form:option>                        
                        </c:if>
                    </c:forEach>
                </form:select>
            </td>
        </tr>
        <tr>
            <td><form:label path="nhaxuatban"> Nhà Xuất Bản</form:label></td>
                <td>
                <form:select path="nhaxuatban" cssStyle="width:215px">
                    <c:forEach items="${nhaXuatBan}" var="nhaxuatban">
                        <c:if test="${nhaxuatban.manxb eq sach.nhaxuatban.manxb}">
                            <form:option selected="true" value="${nhaxuatban.manxb}">${nhaxuatban.tennxb}</form:option>
                        </c:if>
                        <c:if test="${nhaxuatban.manxb != sach.nhaxuatban.manxb}">
                            <form:option value="${nhaxuatban.manxb}">${nhaxuatban.tennxb}</form:option>
                        </c:if>
                    </c:forEach>
                </form:select>
            </td>
        </tr>
        <tr>
            <td><form:label path="namxb">Năm XB</form:label></td>
            <td><form:input path="namxb" cssStyle="width:215px" class="validate[required,custom[date]]"/></td>
            <td rowspan="2"><form:label path="giabia">Hình</form:label></td>
                <td rowspan="2"><input name="anh" type="file" /></td>
            </tr>
            <tr>
                <td><form:label path="giabia">Giá Bìa</form:label></td>
            <td><form:input path="giabia" cssStyle="width:215px" class="validate[required,custom[onlyNumber]]" /></td>
        </tr>
        <tr>
            <td><form:label path="giamgia">Giảm giá</form:label></td>
            <td><form:input path="giamgia" class="validate[custom[onlyNumber]]"/></td>
            <td><form:label path="soluong">Số Lượng</form:label></td>
            <td><form:input path="soluong" class="validate[required,custom[onlyNumber]]"/></td>
        </tr>
        <tr>
            <td colspan="4" align="center">                
                <div id="comment-box">
                    <input type="submit" class="button-primary" value="Sửa"/>
                </div>
            </td>
        </tr>
    </table>
</form:form>
